from django_filters import rest_framework

from apps.suites.models import Suite, CrontabTask


class SuiteFilter(rest_framework.FilterSet):
    name = rest_framework.CharFilter(lookup_expr='contains')

    class Meta:
        model = Suite
        fields = ['name', 'project']


class CrontabTaskFilter(rest_framework.FilterSet):

    suite_name = rest_framework.CharFilter(lookup_expr='contains', field_name='suite__name')
    env_name = rest_framework.CharFilter(lookup_expr='contains', field_name='env__name')

    class Meta:
        model = CrontabTask
        fields = ['project', 'suite_name', 'env_name']